package com.zzptc.mzb.statisticaltable;

import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;

import java.util.ArrayList;


public class BlankFragment extends Fragment {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_blank, container, false);
        //实例化布局控件
        LineChart lineChart = view.findViewById(R.id.line_Chart);
        ArrayList<Entry> list = new ArrayList<>();//创建一个集合
        //定点
        list.add(new Entry(1, 2));
        list.add(new Entry(2, 3));
        list.add(new Entry(3, 5));
        list.add(new Entry(4, 0));
        list.add(new Entry(5, 9));

        ArrayList<Entry> list1 = new ArrayList<>();//创建一个集合
        //定点
        list1.add(new Entry(1, 8));
        list1.add(new Entry(2, 6));
        list1.add(new Entry(3, 7));
        list1.add(new Entry(4, 5));
        list1.add(new Entry(5, 9));
        //两个参数
        LineDataSet lineDataSet = new LineDataSet(list, "");
        LineDataSet lineDataSet1 = new LineDataSet(list1, "");
        //标点颜色
        lineDataSet.setCircleColor(Color.BLUE);
        lineDataSet1.setCircleColor(Color.RED);
        //设置线的颜色
        lineDataSet1.setColor(Color.RED);
        //线宽
        lineDataSet.setLineWidth(2f);
        //将两条的数据放入集合
//        ArrayList<ILineDataSet>lineDataSets=new ArrayList<>();
//        lineDataSets.add(lineDataSet);
//        lineDataSets.add(lineDataSet1);

        LineData lineData = new LineData(lineDataSet);
        lineData.addDataSet(lineDataSet1);
        lineChart.setData(lineData);
        XAxis xAxis = lineChart.getXAxis();
        //设置x轴
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        //最大值
        xAxis.setAxisMaximum(5);
        //最小值
        xAxis.setAxisMinimum(1);
        xAxis.setLabelCount(5, false);
        return view;
    }
}
